#!/usr/bin/env python
# encoding: utf-8

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
import flask.ext.whooshalchemy as whooshalchemy


app = Flask(__name__)
#app.config['SQLALCHEMY_DATABASE_URL']="mysql://root:123456@127.0.0.1/blog"
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:123456@127.0.0.1/blog'
db = SQLAlchemy(app)


class contact(db.Model):
    __tablename__ = 'tel'
    __searchable__ = ['username','job','tel']
    id = db.Column(db.Integer,primary_key=True)
    username = db.Column(db.String(100),nullable=False)
    job = db.Column(db.String(100),nullable=False)
    tel = db.Column(db.String(20),nullable=False)
    number = db.Column(db.String(20),nullable=False)

    def __init__(self,username,job,tel,number):
        self.username = username
        self.job = job
        self.tel = tel
        self.number = number

    def __repr__(self):
        return "<%s >" %self.username


class computer(db.Model):
    __tablename__ = 'computer'
    __searchable__ = ['username','job','mac','ip','number']
    id = db.Column(db.Integer,primary_key=True)
    number = db.Column(db.String(20),nullable=False)
    username = db.Column(db.String(100),nullable=False)
    job = db.Column(db.String(100),nullable=False)
    ip = db.Column(db.String(20),nullable=False)
    mac = db.Column(db.String(40),nullable=False)
    mark = db.Column(db.String(300),nullable=False)
    def __init__(self,number,username,job,ip,mac,mark):
        self.number = number
        self.username = username
        self.job = job
        self.ip = ip
        self.mac = mac
        self.mark = mark
    def __repr__(self):
        return "<%s >" %self.username



if __name__ == '__main__':
    db.create_all()

